﻿namespace QLPhongKham.UC
{
    using ConfigDatabase.Class;
    using DevExpress.Data;
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraTab;
    using QLPhongKham.Access;
    using QLPhongKham.Access.Duoc;
    using QLPhongKham.BaseClass.Duoc;
    using QLPhongKham.Report;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class ucd_bc_tonkhochitiet : XtraUserControl
    {
        private ConnectDatabase _condata;
        private DTonKho _dton;
        private General _xuli;
        private SimpleButton btnin;
        private SimpleButton btnketthuc;
        private SimpleButton btnxem;
        private LookUpEdit cbbquy;
        private CheckEdit chkloai;
        private CheckEdit chknhom;
        private CheckedListBoxControl clbloai;
        private CheckedListBoxControl clbnhom;
        private IContainer components;
        private GridControl gridds;
        private GridColumn gridds_dvt;
        private GridColumn gridds_gianhap;
        private GridColumn gridds_hamluong;
        private GridColumn gridds_handung;
        private GridColumn gridds_id;
        private GridColumn gridds_losx;
        private GridColumn gridds_ma;
        private GridColumn gridds_slnhap;
        private GridColumn gridds_sltoncuoi;
        private GridColumn gridds_sltondau;
        private GridColumn gridds_slxuat;
        private GridColumn gridds_ten;
        private GridColumn gridds_tenvitrikho;
        private GridView gridView1;
        private GroupControl groupControl1;
        private Label label1;
        private Label label4;
        private Label label5;
        private MaskedTextBox mtbdenngay;
        private MaskedTextBox mtbtungay;
        private RadioButton rdbngay;
        private RadioButton rdbquy;
        private RepositoryItemTextEdit repositoryItemTextEdit1;
        private TextEdit txtnam;

        public ucd_bc_tonkhochitiet()
        {
            this.components = null;
            this.InitializeComponent();
            this._condata = new ConnectDatabase();
        }

        public ucd_bc_tonkhochitiet(ConnectDatabase condata)
        {
            this.components = null;
            this.InitializeComponent();
            this._condata = condata;
        }

        private void btnin_Click(object sender, EventArgs e)
        {
            DataTable dataSource = (DataTable) this.gridds.DataSource;
            dataSource.AcceptChanges();
            try
            {
                dataSource.Columns.Add("tungay");
                dataSource.Columns.Add("denngay");
                dataSource.Columns.Add("quy");
                dataSource.Columns.Add("nam");
                dataSource.Columns.Add("xemquy");
            }
            catch
            {
            }
            for (int i = 0; i < dataSource.Rows.Count; i++)
            {
                dataSource.Rows[i]["tungay"] = this.mtbtungay.Text.Substring(0, 10);
                dataSource.Rows[i]["denngay"] = this.mtbdenngay.Text.Substring(0, 10);
                dataSource.Rows[i]["quy"] = this.cbbquy.GetColumnValue("quy");
                dataSource.Rows[i]["nam"] = this.txtnam.Text;
                dataSource.Rows[i]["xemquy"] = this.rdbquy.Checked ? 1 : 0;
            }
            DataSet data = new DataSet();
            data.Tables.Add(dataSource.Copy());
            data.WriteXml("dataxml//d_bc_tonkhochitiet.xml", XmlWriteMode.WriteSchema);
            new XtraReport1().f_load(data, "d_bc_tonkhochitiet.repx");
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
            }
        }

        private void btnmoi_Click(object sender, EventArgs e)
        {
            DataTable table = new DataTable();
            this.txtnam.EditValue = DateTime.Now.ToString("yyyy");
            this.rdbquy_CheckedChanged(null, null);
            DateTime time = new DateTime(int.Parse(this.mtbtungay.Text.Substring(6, 4)), int.Parse(this.mtbtungay.Text.Substring(3, 2)), int.Parse(this.mtbtungay.Text.Substring(0, 2)));
            DateTime time2 = new DateTime(int.Parse(this.mtbdenngay.Text.Substring(6, 4)), int.Parse(this.mtbdenngay.Text.Substring(3, 2)), int.Parse(this.mtbdenngay.Text.Substring(0, 2)));
            string formatdate = "dd/MM/yyyy";
            string manhom = this.f_get_manhom();
            string maloai = this.f_get_maloai();
            table = this._dton.f_load_tonkhochitiet(time.ToString(formatdate), time2.ToString(formatdate), formatdate, manhom, maloai).Tables[0];
            DataView defaultView = table.DefaultView;
            defaultView.RowFilter = "sltoncuoi>0";
            DataTable table2 = defaultView.ToTable();
            this.gridds.DataSource = table2;
        }

        private void cbbquy_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                string str = this.cbbquy.GetColumnValue("tungay").ToString() + "/" + this.txtnam.Text;
                string str2 = this.cbbquy.GetColumnValue("denngay").ToString() + "/" + this.txtnam.Text;
                this.mtbdenngay.Text = str2;
                this.mtbtungay.Text = str;
            }
            catch
            {
            }
        }

        private void chkloai_CheckedChanged(object sender, EventArgs e)
        {
            DataTable dataSource = (DataTable) this.clbloai.DataSource;
            for (int i = 0; i < dataSource.Rows.Count; i++)
            {
                this.clbloai.SetItemChecked(i, this.chkloai.Checked);
            }
        }

        private void chknhom_CheckedChanged(object sender, EventArgs e)
        {
            DataTable dataSource = (DataTable) this.clbnhom.DataSource;
            for (int i = 0; i < dataSource.Rows.Count; i++)
            {
                this.clbnhom.SetItemChecked(i, this.chknhom.Checked);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private string f_get_maloai()
        {
            string str = ",";
            DataTable dataSource = (DataTable) this.clbloai.DataSource;
            for (int i = 0; i < dataSource.Rows.Count; i++)
            {
                if (this.clbloai.GetItemChecked(i) && (str.IndexOf("," + this.clbloai.GetItemValue(i).ToString() + ",") < 0))
                {
                    str = str + this.clbloai.GetItemValue(i).ToString() + ",";
                }
            }
            return str.Trim(new char[] { ',' });
        }

        private string f_get_manhom()
        {
            string str = ",";
            DataTable dataSource = (DataTable) this.clbnhom.DataSource;
            for (int i = 0; i < dataSource.Rows.Count; i++)
            {
                if (this.clbnhom.GetItemChecked(i) && (str.IndexOf("," + this.clbnhom.GetItemValue(i).ToString() + ",") < 0))
                {
                    str = str + this.clbnhom.GetItemValue(i).ToString() + ",";
                }
            }
            return str.Trim(new char[] { ',' });
        }

        private void f_load_loaidp()
        {
            try
            {
                this.clbloai.DataSource = new dtoDDMLoaiDuocPham(this._xuli.pConFigData).LoadAll();
                this.clbloai.DisplayMember = "ten";
                this.clbloai.ValueMember = "id";
            }
            catch
            {
            }
        }

        private void f_load_nhomdp()
        {
            try
            {
                this.clbnhom.DataSource = new dtoDDMNhomDuocPham(this._xuli.pConFigData).LoadAll();
                this.clbnhom.DisplayMember = "ten";
                this.clbnhom.ValueMember = "id";
            }
            catch
            {
            }
        }

        private void f_load_quy()
        {
            try
            {
                DataTable table = new DataTable();
                table.Columns.Add("quy");
                table.Columns.Add("tungay");
                table.Columns.Add("denngay");
                table.Rows.Add(new object[] { "I", "01/01", "31/03" });
                table.Rows.Add(new object[] { "II", "01/04", "30/06" });
                table.Rows.Add(new object[] { "III", "01/07", "30/09" });
                table.Rows.Add(new object[] { "IV", "01/10", "31/12" });
                this.cbbquy.Properties.DataSource = table;
                this.cbbquy.Properties.ValueMember = "quy";
                this.cbbquy.Properties.DisplayMember = "quy";
            }
            catch
            {
            }
        }

        private void gridView1_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
        {
        }

        private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ucd_bc_tonkhochitiet));
            this.label1 = new Label();
            this.btnxem = new SimpleButton();
            this.btnketthuc = new SimpleButton();
            this.gridView1 = new GridView();
            this.gridds_ma = new GridColumn();
            this.repositoryItemTextEdit1 = new RepositoryItemTextEdit();
            this.gridds_ten = new GridColumn();
            this.gridds_id = new GridColumn();
            this.gridds_dvt = new GridColumn();
            this.gridds_sltondau = new GridColumn();
            this.gridds_slnhap = new GridColumn();
            this.gridds_slxuat = new GridColumn();
            this.gridds_sltoncuoi = new GridColumn();
            this.gridds_gianhap = new GridColumn();
            this.gridds_losx = new GridColumn();
            this.gridds_handung = new GridColumn();
            this.gridds_tenvitrikho = new GridColumn();
            this.gridds_hamluong = new GridColumn();
            this.gridds = new GridControl();
            this.btnin = new SimpleButton();
            this.groupControl1 = new GroupControl();
            this.mtbdenngay = new MaskedTextBox();
            this.mtbtungay = new MaskedTextBox();
            this.chkloai = new CheckEdit();
            this.chknhom = new CheckEdit();
            this.clbloai = new CheckedListBoxControl();
            this.clbnhom = new CheckedListBoxControl();
            this.txtnam = new TextEdit();
            this.cbbquy = new LookUpEdit();
            this.label4 = new Label();
            this.label5 = new Label();
            this.rdbquy = new RadioButton();
            this.rdbngay = new RadioButton();
            this.gridView1.BeginInit();
            this.repositoryItemTextEdit1.BeginInit();
            this.gridds.BeginInit();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.chkloai.Properties.BeginInit();
            this.chknhom.Properties.BeginInit();
            ((ISupportInitialize) this.clbloai).BeginInit();
            ((ISupportInitialize) this.clbnhom).BeginInit();
            this.txtnam.Properties.BeginInit();
            this.cbbquy.Properties.BeginInit();
            base.SuspendLayout();
            this.label1.BackColor = Color.ForestGreen;
            this.label1.Dock = DockStyle.Top;
            this.label1.Font = new Font("Tahoma", 16f);
            this.label1.ForeColor = Color.Yellow;
            this.label1.Location = new Point(0, 0);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x400, 0x30);
            this.label1.TabIndex = 1;
            this.label1.Text = "B\x00c1O C\x00c1O TỒN KHO CHI TIẾT";
            this.label1.TextAlign = ContentAlignment.MiddleLeft;
            this.btnxem.Appearance.Options.UseTextOptions = true;
            this.btnxem.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnxem.Image = Properties.Resources.imgrefresh;// (Image)manager.GetObject("btnxem.Image");
            this.btnxem.Location = new Point(0x76, 0x54);
            this.btnxem.Name = "btnxem";
            this.btnxem.Size = new Size(0x4b, 0x17);
            this.btnxem.TabIndex = 10;
            this.btnxem.Text = " &Xem";
            this.btnxem.Click += new EventHandler(this.btnmoi_Click);
            this.btnketthuc.Appearance.Options.UseTextOptions = true;
            this.btnketthuc.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnketthuc.Image = Properties.Resources.imgclose;// (Image)manager.GetObject("btnketthuc.Image");
            this.btnketthuc.Location = new Point(0xfb, 0x54);
            this.btnketthuc.Name = "btnketthuc";
            this.btnketthuc.Size = new Size(0x65, 0x17);
            this.btnketthuc.TabIndex = 0x10;
            this.btnketthuc.Text = " &Kết th\x00fac [F12]";
            this.btnketthuc.Click += new EventHandler(this.btnketthuc_Click);
            this.gridView1.Appearance.ColumnFilterButton.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.ColumnFilterButton.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.ColumnFilterButton.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseForeColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.BackColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.ColumnFilterButtonActive.BorderColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.ColumnFilterButtonActive.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
            this.gridView1.Appearance.Empty.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Empty.BackColor2 = Color.White;
            this.gridView1.Appearance.Empty.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(0xdd, 0xe3, 0xf5);
            this.gridView1.Appearance.EvenRow.BorderColor = Color.FromArgb(0xdd, 0xe3, 0xf5);
            this.gridView1.Appearance.EvenRow.ForeColor = Color.Black;
            this.gridView1.Appearance.EvenRow.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterCloseButton.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FilterCloseButton.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FilterCloseButton.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterPanel.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.FilterPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.FilterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.FixedLine.BackColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.FixedLine.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.BackColor = Color.White;
            this.gridView1.Appearance.FocusedCell.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedCell.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.Options.UseForeColor = true;
            this.gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(0x81, 0xab, 0xb1);
            this.gridView1.Appearance.FocusedRow.ForeColor = Color.White;
            this.gridView1.Appearance.FocusedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FooterPanel.BackColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FooterPanel.BorderColor = Color.FromArgb(0xca, 0xdd, 0xd0);
            this.gridView1.Appearance.FooterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FooterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupButton.BackColor = Color.FromArgb(0xb2, 0xd1, 0xbc);
            this.gridView1.Appearance.GroupButton.BorderColor = Color.FromArgb(0xb2, 0xd1, 0xbc);
            this.gridView1.Appearance.GroupButton.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.BackColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupFooter.BorderColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupFooter.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupFooter.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupPanel.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.GroupPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.GroupPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupRow.BackColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupRow.BorderColor = Color.FromArgb(0xd7, 0xea, 0xdd);
            this.gridView1.Appearance.GroupRow.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupRow.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HeaderPanel.BackColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.HeaderPanel.BorderColor = Color.FromArgb(0xd3, 0xe2, 0xd8);
            this.gridView1.Appearance.HeaderPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.HideSelectionRow.BackColor = Color.FromArgb(0xba, 0xd3, 0xd7);
            this.gridView1.Appearance.HideSelectionRow.ForeColor = Color.FromArgb(0x68, 130, 0x86);
            this.gridView1.Appearance.HideSelectionRow.Options.UseBackColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HorzLine.BackColor = Color.FromArgb(0xac, 0xc5, 180);
            this.gridView1.Appearance.HorzLine.BorderColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.HorzLine.Options.UseBackColor = true;
            this.gridView1.Appearance.HorzLine.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.BorderColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.ForeColor = Color.Black;
            this.gridView1.Appearance.OddRow.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.Options.UseForeColor = true;
            this.gridView1.Appearance.Preview.BackColor = Color.FromArgb(250, 250, 240);
            this.gridView1.Appearance.Preview.Font = new Font("Verdana", 7.5f);
            this.gridView1.Appearance.Preview.ForeColor = Color.FromArgb(0x68, 130, 0x86);
            this.gridView1.Appearance.Preview.Options.UseBackColor = true;
            this.gridView1.Appearance.Preview.Options.UseFont = true;
            this.gridView1.Appearance.Preview.Options.UseForeColor = true;
            this.gridView1.Appearance.Row.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Row.ForeColor = Color.Black;
            this.gridView1.Appearance.Row.Options.UseBackColor = true;
            this.gridView1.Appearance.Row.Options.UseForeColor = true;
            this.gridView1.Appearance.RowSeparator.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.RowSeparator.BackColor2 = Color.White;
            this.gridView1.Appearance.RowSeparator.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.BackColor = Color.FromArgb(0x9f, 0xc9, 0xcf);
            this.gridView1.Appearance.SelectedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.SelectedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.TopNewRow.BackColor = Color.White;
            this.gridView1.Appearance.TopNewRow.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.BackColor = Color.FromArgb(0xac, 0xc5, 180);
            this.gridView1.Appearance.VertLine.BorderColor = Color.FromArgb(0x75, 0x88, 0x7a);
            this.gridView1.Appearance.VertLine.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.Options.UseBorderColor = true;
            this.gridView1.Columns.AddRange(new GridColumn[] { this.gridds_ma, this.gridds_ten, this.gridds_id, this.gridds_dvt, this.gridds_sltondau, this.gridds_slnhap, this.gridds_slxuat, this.gridds_sltoncuoi, this.gridds_gianhap, this.gridds_losx, this.gridds_handung, this.gridds_tenvitrikho, this.gridds_hamluong });
            this.gridView1.GridControl = this.gridds;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsView.AutoCalcPreviewLineCount = true;
            this.gridView1.OptionsView.EnableAppearanceEvenRow = true;
            this.gridView1.OptionsView.EnableAppearanceOddRow = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.CustomSummaryCalculate += new CustomSummaryEventHandler(this.gridView1_CustomSummaryCalculate);
            this.gridView1.FocusedRowChanged += new FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);
            this.gridds_ma.Caption = "M\x00e3 số";
            this.gridds_ma.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ma.FieldName = "madp";
            this.gridds_ma.Name = "gridds_ma";
            this.gridds_ma.OptionsColumn.AllowEdit = false;
            this.gridds_ma.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Count, "ma", "{0:n0}") });
            this.gridds_ma.Visible = true;
            this.gridds_ma.VisibleIndex = 0;
            this.gridds_ma.Width = 0x29;
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.DisplayFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            this.repositoryItemTextEdit1.NullText = "0";
            this.repositoryItemTextEdit1.ReadOnly = true;
            this.gridds_ten.Caption = "T\x00ean dược phẩm";
            this.gridds_ten.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_ten.FieldName = "tendp";
            this.gridds_ten.Name = "gridds_ten";
            this.gridds_ten.OptionsColumn.AllowEdit = false;
            this.gridds_ten.OptionsColumn.AllowSort = DefaultBoolean.True;
            this.gridds_ten.OptionsColumn.FixedWidth = true;
            this.gridds_ten.Visible = true;
            this.gridds_ten.VisibleIndex = 1;
            this.gridds_ten.Width = 0x1cb;
            this.gridds_id.Caption = "id";
            this.gridds_id.FieldName = "iddp";
            this.gridds_id.Name = "gridds_id";
            this.gridds_dvt.Caption = "ĐVT";
            this.gridds_dvt.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_dvt.FieldName = "dvt";
            this.gridds_dvt.Name = "gridds_dvt";
            this.gridds_dvt.OptionsColumn.AllowEdit = false;
            this.gridds_dvt.Visible = true;
            this.gridds_dvt.VisibleIndex = 2;
            this.gridds_dvt.Width = 0x1b;
            this.gridds_sltondau.Caption = "Tồn đầu";
            this.gridds_sltondau.ColumnEdit = this.repositoryItemTextEdit1;
            this.gridds_sltondau.FieldName = "sltondau";
            this.gridds_sltondau.Name = "gridds_sltondau";
            this.gridds_sltondau.OptionsColumn.AllowEdit = false;
            this.gridds_sltondau.OptionsColumn.FixedWidth = true;
            this.gridds_sltondau.Visible = true;
            this.gridds_sltondau.VisibleIndex = 7;
            this.gridds_sltondau.Width = 0x3f;
            this.gridds_slnhap.Caption = "Nhập";
            this.gridds_slnhap.DisplayFormat.FormatType = FormatType.Numeric;
            this.gridds_slnhap.FieldName = "slnhap";
            this.gridds_slnhap.Name = "gridds_slnhap";
            this.gridds_slnhap.OptionsColumn.AllowEdit = false;
            this.gridds_slnhap.OptionsColumn.ReadOnly = true;
            this.gridds_slnhap.Visible = true;
            this.gridds_slnhap.VisibleIndex = 8;
            this.gridds_slnhap.Width = 0x26;
            this.gridds_slxuat.Caption = "Xuất";
            this.gridds_slxuat.FieldName = "slxuat";
            this.gridds_slxuat.Name = "gridds_slxuat";
            this.gridds_slxuat.OptionsColumn.AllowEdit = false;
            this.gridds_slxuat.OptionsColumn.ReadOnly = true;
            this.gridds_slxuat.Visible = true;
            this.gridds_slxuat.VisibleIndex = 9;
            this.gridds_slxuat.Width = 0x1f;
            this.gridds_sltoncuoi.Caption = "Tồn cuối";
            this.gridds_sltoncuoi.DisplayFormat.FormatType = FormatType.Numeric;
            this.gridds_sltoncuoi.FieldName = "sltoncuoi";
            this.gridds_sltoncuoi.Name = "gridds_sltoncuoi";
            this.gridds_sltoncuoi.OptionsColumn.AllowEdit = false;
            this.gridds_sltoncuoi.OptionsColumn.ReadOnly = true;
            this.gridds_sltoncuoi.Visible = true;
            this.gridds_sltoncuoi.VisibleIndex = 10;
            this.gridds_sltoncuoi.Width = 0x43;
            this.gridds_gianhap.Caption = "Gi\x00e1 nhập";
            this.gridds_gianhap.DisplayFormat.FormatString = "n0";
            this.gridds_gianhap.DisplayFormat.FormatType = FormatType.Numeric;
            this.gridds_gianhap.FieldName = "gianhap";
            this.gridds_gianhap.Name = "gridds_gianhap";
            this.gridds_gianhap.OptionsColumn.ReadOnly = true;
            this.gridds_gianhap.Visible = true;
            this.gridds_gianhap.VisibleIndex = 6;
            this.gridds_gianhap.Width = 0x30;
            this.gridds_losx.Caption = "L\x00f4 SX";
            this.gridds_losx.FieldName = "losx";
            this.gridds_losx.Name = "gridds_losx";
            this.gridds_losx.OptionsColumn.ReadOnly = true;
            this.gridds_losx.Visible = true;
            this.gridds_losx.VisibleIndex = 4;
            this.gridds_losx.Width = 0x23;
            this.gridds_handung.Caption = "Date";
            this.gridds_handung.FieldName = "handung";
            this.gridds_handung.Name = "gridds_handung";
            this.gridds_handung.OptionsColumn.ReadOnly = true;
            this.gridds_handung.Visible = true;
            this.gridds_handung.VisibleIndex = 5;
            this.gridds_handung.Width = 0x2c;
            this.gridds_tenvitrikho.Caption = "Vị tr\x00ed trong kho";
            this.gridds_tenvitrikho.FieldName = "tenvitrikho";
            this.gridds_tenvitrikho.Name = "gridds_tenvitrikho";
            this.gridds_tenvitrikho.OptionsColumn.ReadOnly = true;
            this.gridds_tenvitrikho.Width = 0x53;
            this.gridds_hamluong.Caption = "H\x00e0m lượng";
            this.gridds_hamluong.FieldName = "hamluong";
            this.gridds_hamluong.Name = "gridds_hamluong";
            this.gridds_hamluong.OptionsColumn.ReadOnly = true;
            this.gridds_hamluong.Visible = true;
            this.gridds_hamluong.VisibleIndex = 3;
            this.gridds_hamluong.Width = 70;
            this.gridds.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.gridds.Location = new Point(0, 0xa8);
            this.gridds.MainView = this.gridView1;
            this.gridds.Name = "gridds";
            this.gridds.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemTextEdit1 });
            this.gridds.Size = new Size(0x400, 0xf7);
            this.gridds.TabIndex = 0x11;
            this.gridds.ViewCollection.AddRange(new BaseView[] { this.gridView1 });
            this.btnin.Image = Properties.Resources.imgprint;// (Image)manager.GetObject("btnin.Image");
            this.btnin.Location = new Point(0xc7, 0x54);
            this.btnin.Name = "btnin";
            this.btnin.Size = new Size(0x30, 0x17);
            this.btnin.TabIndex = 14;
            this.btnin.Text = " &In";
            this.btnin.Click += new EventHandler(this.btnin_Click);
            this.groupControl1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.groupControl1.AppearanceCaption.Font = new Font("Tahoma", 10f, FontStyle.Bold);
            this.groupControl1.AppearanceCaption.Options.UseFont = true;
            this.groupControl1.Controls.Add(this.mtbdenngay);
            this.groupControl1.Controls.Add(this.mtbtungay);
            this.groupControl1.Controls.Add(this.chkloai);
            this.groupControl1.Controls.Add(this.chknhom);
            this.groupControl1.Controls.Add(this.clbloai);
            this.groupControl1.Controls.Add(this.clbnhom);
            this.groupControl1.Controls.Add(this.txtnam);
            this.groupControl1.Controls.Add(this.cbbquy);
            this.groupControl1.Controls.Add(this.label4);
            this.groupControl1.Controls.Add(this.btnketthuc);
            this.groupControl1.Controls.Add(this.label5);
            this.groupControl1.Controls.Add(this.btnxem);
            this.groupControl1.Controls.Add(this.btnin);
            this.groupControl1.Controls.Add(this.rdbquy);
            this.groupControl1.Controls.Add(this.rdbngay);
            this.groupControl1.Location = new Point(0, 0x33);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new Size(0x400, 0x75);
            this.groupControl1.TabIndex = 0x12;
            this.groupControl1.Text = "T\x00f9y chọn";
            this.mtbdenngay.Location = new Point(0x10c, 0x37);
            this.mtbdenngay.Mask = "00/00/0000";
            this.mtbdenngay.Name = "mtbdenngay";
            this.mtbdenngay.Size = new Size(100, 0x15);
            this.mtbdenngay.TabIndex = 4;
            this.mtbdenngay.ValidatingType = typeof(DateTime);
            this.mtbdenngay.Validated += new EventHandler(this.mtbdenngay_Validated);
            this.mtbtungay.Location = new Point(0x63, 0x37);
            this.mtbtungay.Mask = "00/00/0000";
            this.mtbtungay.Name = "mtbtungay";
            this.mtbtungay.Size = new Size(100, 0x15);
            this.mtbtungay.TabIndex = 3;
            this.mtbtungay.ValidatingType = typeof(DateTime);
            this.mtbtungay.Validated += new EventHandler(this.mtbtungay_Validated);
            this.chkloai.Location = new Point(0x283, 0x18);
            this.chkloai.Name = "chkloai";
            this.chkloai.Properties.Caption = "Tất cả loại";
            this.chkloai.Size = new Size(0xe1, 0x13);
            this.chkloai.TabIndex = 0x15;
            this.chkloai.CheckedChanged += new EventHandler(this.chkloai_CheckedChanged);
            this.chknhom.Location = new Point(0x176, 0x18);
            this.chknhom.Name = "chknhom";
            this.chknhom.Properties.Caption = "Tất cả nh\x00f3m";
            this.chknhom.Size = new Size(0xe1, 0x13);
            this.chknhom.TabIndex = 0x15;
            this.chknhom.CheckedChanged += new EventHandler(this.chknhom_CheckedChanged);
            this.clbloai.Location = new Point(0x283, 0x2b);
            this.clbloai.Name = "clbloai";
            this.clbloai.Size = new Size(0x107, 0x40);
            this.clbloai.TabIndex = 20;
            this.clbnhom.Location = new Point(0x176, 0x2b);
            this.clbnhom.Name = "clbnhom";
            this.clbnhom.Size = new Size(0x107, 0x40);
            this.clbnhom.TabIndex = 20;
            this.txtnam.EditValue = 0;
            this.txtnam.Location = new Point(0x10c, 0x1b);
            this.txtnam.Name = "txtnam";
            this.txtnam.Properties.Appearance.Options.UseTextOptions = true;
            this.txtnam.Properties.Appearance.TextOptions.HAlignment = HorzAlignment.Far;
            this.txtnam.Size = new Size(100, 20);
            this.txtnam.TabIndex = 0x12;
            this.cbbquy.EditValue = "<Null>";
            this.cbbquy.Location = new Point(0x63, 0x1b);
            this.cbbquy.Name = "cbbquy";
            this.cbbquy.Properties.Appearance.Font = new Font("Tahoma", 10f);
            this.cbbquy.Properties.Appearance.Options.UseFont = true;
            this.cbbquy.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbquy.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("quy", "Q\x00fay"), new LookUpColumnInfo("tungay", "tu", 20, FormatType.None, "", false, HorzAlignment.Default), new LookUpColumnInfo("den", "den", 20, FormatType.None, "", false, HorzAlignment.Default) });
            this.cbbquy.Properties.NullText = "";
            this.cbbquy.Size = new Size(100, 0x16);
            this.cbbquy.TabIndex = 0x11;
            this.cbbquy.EditValueChanged += new EventHandler(this.cbbquy_EditValueChanged);
            this.label4.Font = new Font("Tahoma", 10f);
            this.label4.Location = new Point(200, 0x3b);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x47, 0x13);
            this.label4.TabIndex = 2;
            this.label4.Text = "đến ng\x00e0y:";
            this.label4.TextAlign = ContentAlignment.TopRight;
            this.label5.Font = new Font("Tahoma", 10f);
            this.label5.Location = new Point(200, 30);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x47, 0x13);
            this.label5.TabIndex = 2;
            this.label5.Text = "Năm:";
            this.label5.TextAlign = ContentAlignment.TopRight;
            this.rdbquy.Checked = true;
            this.rdbquy.Font = new Font("Tahoma", 10f);
            this.rdbquy.Location = new Point(0x13, 0x1a);
            this.rdbquy.Name = "rdbquy";
            this.rdbquy.Size = new Size(0x54, 0x17);
            this.rdbquy.TabIndex = 0x13;
            this.rdbquy.TabStop = true;
            this.rdbquy.Text = "Qu\x00fd:";
            this.rdbquy.TextAlign = ContentAlignment.MiddleRight;
            this.rdbquy.UseVisualStyleBackColor = true;
            this.rdbquy.CheckedChanged += new EventHandler(this.rdbquy_CheckedChanged);
            this.rdbngay.Font = new Font("Tahoma", 10f);
            this.rdbngay.Location = new Point(0x13, 0x37);
            this.rdbngay.Name = "rdbngay";
            this.rdbngay.Size = new Size(0x54, 0x1c);
            this.rdbngay.TabIndex = 0x13;
            this.rdbngay.Text = "Từ ng\x00e0y:";
            this.rdbngay.TextAlign = ContentAlignment.MiddleRight;
            this.rdbngay.UseVisualStyleBackColor = true;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.groupControl1);
            base.Controls.Add(this.gridds);
            base.Controls.Add(this.label1);
            base.Name = "ucd_bc_tonkhochitiet";
            base.Size = new Size(0x400, 0x19f);
            base.Load += new EventHandler(this.ucDMSanPham_Load);
            base.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.gridView1.EndInit();
            this.repositoryItemTextEdit1.EndInit();
            this.gridds.EndInit();
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.groupControl1.PerformLayout();
            this.chkloai.Properties.EndInit();
            this.chknhom.Properties.EndInit();
            ((ISupportInitialize) this.clbloai).EndInit();
            ((ISupportInitialize) this.clbnhom).EndInit();
            this.txtnam.Properties.EndInit();
            this.cbbquy.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void mtbdenngay_Validated(object sender, EventArgs e)
        {
            try
            {
                DateTime time = new DateTime(int.Parse(this.mtbdenngay.Text.Substring(6, 4)), int.Parse(this.mtbdenngay.Text.Substring(3, 2)), int.Parse(this.mtbdenngay.Text.Substring(0, 2)));
                DateTime time2 = new DateTime(int.Parse(this.mtbtungay.Text.Substring(6, 4)), int.Parse(this.mtbtungay.Text.Substring(3, 2)), int.Parse(this.mtbtungay.Text.Substring(0, 2)));
                if (time2 > time)
                {
                    string str = this.mtbtungay.Text.Substring(20, 10);
                }
            }
            catch
            {
                MessageBox.Show("Ng\x00e0y kh\x00f4ng hợp lệ.", "Th\x00f4ng b\x00e1o");
                this.mtbdenngay.Focus();
            }
        }

        private void mtbtungay_Validated(object sender, EventArgs e)
        {
            try
            {
                DateTime time = new DateTime(int.Parse(this.mtbtungay.Text.Substring(6, 4)), int.Parse(this.mtbtungay.Text.Substring(3, 2)), int.Parse(this.mtbtungay.Text.Substring(0, 2)));
                DateTime time2 = new DateTime(int.Parse(this.mtbdenngay.Text.Substring(6, 4)), int.Parse(this.mtbdenngay.Text.Substring(3, 2)), int.Parse(this.mtbdenngay.Text.Substring(0, 2)));
                if (time2 < time)
                {
                    string str = this.mtbtungay.Text.Substring(20, 10);
                }
            }
            catch
            {
                MessageBox.Show("Ng\x00e0y kh\x00f4ng hợp lệ.", "Th\x00f4ng b\x00e1o");
                this.mtbtungay.Focus();
            }
        }

        private void rdbquy_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.cbbquy.Enabled = this.txtnam.Enabled = this.rdbquy.Checked;
                this.mtbtungay.Enabled = this.mtbdenngay.Enabled = !this.rdbquy.Checked;
                if (this.rdbquy.Checked)
                {
                    this.cbbquy_EditValueChanged(null, null);
                }
            }
            catch
            {
            }
        }

        private void ucDMSanPham_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SendKeys.Send("{Tab}");
            }
            else if (e.KeyCode == Keys.F2)
            {
                if (this.btnxem.Enabled)
                {
                    this.btnmoi_Click(null, null);
                }
            }
            else if ((e.KeyCode == Keys.F12) && this.btnketthuc.Enabled)
            {
                this.btnketthuc_Click(null, null);
            }
        }

        private void ucDMSanPham_Load(object sender, EventArgs e)
        {
            this._xuli = new General(this._condata);
            this._dton = new DTonKho(this._xuli.pConFigData);
            this.f_load_nhomdp();
            this.f_load_loaidp();
            this.mtbdenngay.Text = DateTime.Now.ToString("dd/MM/yyyy");
            this.mtbtungay.Text = DateTime.Now.AddMonths(-1).ToString("dd/MM/yyyy");
            this.f_load_quy();
            this.btnmoi_Click(null, null);
        }
    }
}

